<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>简单接口</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="internals2.counter.examples.html">范例</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="internals2.counter.examples.extended.html">扩展接口</a></div>
 <div class="up"><a href="internals2.counter.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="internals2.counter.examples.basic" class="section">
    <h2 class="title">简单接口</h2>
    
    <p class="simpara">
     简单接口提供 3 个简单的函数，实例如下：
    </p>
   
    <div class="example" id="internals2.counter.examples.basic.ex">
     <p><strong>Example #1 &quot;counter&quot;的简单接口</strong></p>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$starting_counter_value&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">counter_get</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">counter_bump</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$second_counter_value&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">counter_get</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">counter_reset</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$final_counter_value&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">counter_get</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%3d&nbsp;%3d&nbsp;%3d"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$starting_counter_value</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$second_counter_value</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$final_counter_value</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

    </div>
    <p class="para">以上例程会输出：</p>
    <div class="example-contents screen">
<div class="cdata"><pre>
  0   1   0</pre></div></div>
   
    <p class="simpara">
     简单接口也提供一系列
     <a href="internals2.counter.constants.html" class="link">INI settings</a>.
    </p>
   </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="internals2.counter.examples.html">范例</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="internals2.counter.examples.extended.html">扩展接口</a></div>
 <div class="up"><a href="internals2.counter.examples.html">范例</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
